package com.face.client.pojo;

import com.arcsoft.AFR_FSDK_FACEMODEL;
import com.face.server.entity.FaceModel;
import com.face.server.entity.Joined;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class FeatureList {

    private byte[] content; // 特征
    private String id; // 对应用户id
    private String name;
    private int type;
    private int size;
    private AFR_FSDK_FACEMODEL facemodel;

    public void init() {
        facemodel = AFR_FSDK_FACEMODEL.build(size, content);
    }

    public FeatureList(FaceModel faceModel) {
        this.content = faceModel.getContent();
        this.size = faceModel.getSize();
        facemodel = AFR_FSDK_FACEMODEL.build(size, content);
    }

    public static List<FeatureList> create(Joined joined) {
        List<FaceModel> faceModels = joined.getFaceModels();
        return faceModels.stream().map(faceModel -> {
            FeatureList featureList = new FeatureList(faceModel);
            featureList.id = joined.getId();
            featureList.type = joined.getType();
            featureList.name = joined.getName();
            return featureList;
        }).collect(Collectors.toList());
    }

}
